package com.demo2do.fms.admin.dao.supplier;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Limit;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.demo2do.fms.entity.appraisal.AppraisalTemplate;
import com.demo2do.fms.entity.appraisal.AppraisalTemplateItem;

/**
 *
 * @author Ark
 *
 */
@Dao("hibernate")
public interface AppraisalTemplateItemDao {
    
    /**
     * @param appraisalTemplate
     * @return
     */
    @Query("SELECT COUNT(*) FROM AppraisalTemplateItem WHERE disabled = false AND parent = :parent")
    public int count(@Variable("parent") AppraisalTemplate appraisalTemplate);
    
    /**
     * 
     * @param appraisalTemplate
     * @return
     */
    @Query("FROM AppraisalTemplateItem WHERE disabled = false AND parent = :parent")
    public List<AppraisalTemplateItem> list(@Variable("parent") AppraisalTemplate appraisalTemplate);

    /**
     * @param appraisalTemplate
     * @param benginIndex
     * @param maxResult
     * @return
     */
    @Limit
    @Query("FROM AppraisalTemplateItem WHERE disabled = false AND parent = :parent ORDER BY createTime ASC")
    public List<AppraisalTemplateItem> list(@Variable("parent") AppraisalTemplate appraisalTemplate, @Variable("beginIndex")int benginIndex, @Variable("maxResult")int maxResult);
    
    /**
     * @param appraisalTemplate
     * @param name
     * @return
     */
    @Query("FROM AppraisalTemplateItem WHERE disabled = false AND parent = :parent AND name = :name")
    public AppraisalTemplateItem getByName(@Variable("parent") AppraisalTemplate appraisalTemplate, @Variable("name") String name);
    
}
